package com.loveprogrammer.eternity.skill.support.skills.passive;

import com.loveprogrammer.eternity.common.Tuple;
import com.loveprogrammer.eternity.model.Character;
import com.loveprogrammer.eternity.model.effect.SuckBloodEffect;
import com.loveprogrammer.eternity.skill.support.skills.AbstractPassiveAuraSkill;
import com.loveprogrammer.eternity.skill.support.states.TreatmentState;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @version 1.0.0
 * @description: 吸血光环
 * @author: eric
 * @date: 2022-08-22 18:07
 **/
public class BloodsuckingAuraSkill extends AbstractPassiveAuraSkill {

    private SuckBloodEffect effect;

    public BloodsuckingAuraSkill(int id, int baseInterval, int level, int order, int maxLevel, String name, String desc) {
        super(id, baseInterval, level, order, maxLevel, name, desc);
    }

    @Override
    protected Tuple<String, List<Character>> skillLaunch(Character character,
                                                         List<? extends Character> attack,
                                                         List<? extends Character> defences) {
        Tuple<String, List<Character>> result = new Tuple<>();
        // 吸血光环，初始100%
        int increment = getHarm(character);
        effect = new SuckBloodEffect(UUID.randomUUID().toString(),increment);
        for (Character member : attack) {
            member.regEffect(effect);
        }
        result.setKey(character.getName() + "释放了技能【" + getName() + " (" + getLevel() + "级)】，所有友方角色获得吸血能力"
                + increment + "%" );
        result.setValue(new ArrayList<>());
        return result;
    }

    @Override
    protected int computeHarm(Character character) {
        return 100 + getLevel() * 5;
    }

    @Override
    protected int computeSecondHarm(Character character) {
        return 0;
    }

    @Override
    public boolean checkLevelUp(int characterLevel) {
        // 每4级升一级
        if(characterLevel % 4 == 0){
            return true;
        }
        return false;
    }

    @Override
    public int defaultHarm() {
        return 0;
    }

    @Override
    public void release(Character character,List<? extends Character> attack, List<? extends Character> defences) {
        // 光环效果取消
        for (Character attackMember : attack) {
            if(attackMember.checkDead()){
                continue;
            }
            attackMember.delEffect(effect);
        }
    }
}
